<template>
  <el-dialog title="客户信息" v-model="showDialog" :width="dialogWidth" :append-to-body="true" :close-on-click-modal="false">
    <div class="bform">
      <div class="h1">
        <div><el-input v-model="ser.key" @blur="searchClick"></el-input></div>
      </div>
      <div class="b1">
        <el-table :data="datas" border class="table" ref="multipleTable" header-cell-class-name="table-header">
          <el-table-column prop="contractCode" label="合同编号"></el-table-column>
          <el-table-column prop="projectName" label="项目名称"></el-table-column>
          <el-table-column prop="leastMoney" label="剩余金额"></el-table-column>
          <el-table-column label="选择" width="90">
            <template #default="scope">
              <el-button @click.stop="check_click(scope.row)">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </el-dialog>
</template>
<script>
let fun = () => {}
export default {
  data() {
    return {
      ser: {
        page: 1,
        row: 10,
        key: '',
        noids: '',
      },
      datas: [],
      total: 0,
      showDialog: false,
      dialogWidth: window.innerWidth > 780 ? '780px' : '100%',
    }
  },
  methods: {
    searchClick() {
      this.ser.page = 1
      this.search()
    },
    show(noids) {
      this.ser.noids = noids
      return new Promise((resolve) => {
        this.ser.key = ''
        this.searchClick()
        this.showDialog = true
        fun = resolve
      })
    },
    search() {
      this.$api.receivemoney.checkcontract(this.ser).then(({ msg: { items, total } }) => {
        this.datas = items
        this.total = total
      })
    },
    check_click(row) {
      this.showDialog = !!fun(row)
    },
  },
}
</script>
<style lang="scss" scoped></style>
